import axios from "axios"
import { Notify } from 'react-vant'
export function login(data: { username: string, password: string }) {
  return async (dispatch: any) => {
    const resp = await axios.post('/api/login', data);
    // 存储
    const { code, data: rawData, message } = resp.data;
    if(code === 200) {
      dispatch({ type: 'loginSuccess', payload: rawData });
      Notify.show({ type: 'success', message })
    } else {
      Notify.show({ type: "danger", message })
    }
  }
} 